<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta charset="utf-8">
	<title>后台用户管理</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="../../layui/css/layui.css" media="all">
	<style>
		.blogUser-con .layui-table-view {
			border: none;
		}
		
		.blogUser-con .layui-table-box {
			margin-top: 10px;
		}
		
		.blogUser-con {
			padding: 0 15px 15px 15px;
			margin-bottom:50px;
		}
		.blogUser-con  .layui-table-tool-self{
			display:none;
		}
		.blogUser-con .not_border_left {
			border-left: none !important;
		}
		
		.blogUser-con .blogUser dl dd.layui-this {
			background-color: #1E9FFF !important;
		}
		
		.blogUser-con .hide {
			display: none;
		}
		
		.blogUser-con .show {
			display: block;
		}
		
		.blogUser-con .btn_size {
			height: 28px !important;
			line-height: 28px !important;
		}
		
		.blogUser-con .layui-table-body table tbody .layui-table-hover {
			background: #fffdd3 !important;
		}
		
		.blogUser-con .layui-table-body table tbody .layui-table-click {
			background: #fdef9b !important;
		}
		
		.blogUser-con .layui-table, .layui-table-view {
			border: none;
			margin-top: 0;
		}
		
		#add-AdminUser {
			display: none;
			z-index: 999 !important;
		}
		
		#add-AdminUser .artTypeLayer {
			width: 90%;
			margin-left: auto;
			margin-right: auto;
			padding-top: 20px;
		}
		.adminuserdetail{
			padding:20px;
			display: none;
		}
		.adminuserdetail table tr td{
			padding: 15px;text-align: center;
		}
		.adminuserdetail .tdbck{
			background: #f2f2f2;
			width: 30%;
		}
	</style>
</head>
<body>

	<div class="blogUser-con">
		
		<script type="text/html" id="barDemo">
			<a class="layui-btn layui-btn-xs" id="edit" lay-event="edit">审核</a>
			<a class="layui-btn layui-btn-warm layui-btn-xs" id="uncheck" lay-event="uncheck">拒审</a>
			<a class="layui-btn layui-btn-danger  layui-btn-xs" lay-event="delete">删除</a>
		</script>

		<!-- 表格开始 -->
		<table class="layui-hide" name="oil" id="oil" lay-filter="notice"></table>
		<!-- 表格结束 -->
		
	</div>
	<script src="../../js/jquery-3.3.1.js" charset="utf-8"></script>
	<script src="../../layui/layui.js" charset="utf-8"></script>
	<script src="../../js/loadselect.js" charset="utf-8"></script>
	<script>
	layui.use([ 'table', 'form', 'layer', 'laydate', 'laytpl', 'element' ], function() {
		var table = layui.table, form = layui.form, 
			layer = layui.layer, $ = layui.jquery,
			laydate = layui.laydate, laytpl = layui.laytpl,
			element = layui.element;
	
	
	function localFormatter(value) {
        if (value == 1) {
            return "<span class='label'  style='color:#ff8080'>未审</span>";
        } else if (value == 2) {
            return "<span class='label'  style='color:#8080ff'>已审</span>";
        } else if (value == 3) {
            return "<span class='label'  style='color:#993366'>拒审</span>";
        }
    }
	
	
		/*加载表格*/
		table.render({
			elem : '#oil',
			id:'oil',
			url : '../../oilmana/getAlloil',
			title : '后台通知管理数据表',
			height: "full-160",
			skin : 'line',
			even : true,
			cols : [ 
			     [ {field : 'oilingid',align : 'center',title : '编号',width : 100,hide : true}, 
			     {field : 'oilingtitle',align : 'center',title : '标题',width : 180}, 
			     {field : 'userid',title : '发布者',align : 'center',width : 150}, 
			     {field : 'username',title : '发布者',align : 'center',width : 150},
			     {field : 'oilingcecontent',align : 'center',title : '文章内容'},
			     {field : 'createtime',align : 'center',title : '发布时间',width : 200},
			     {field : 'ischeck',align : 'center',title : '是否审核',templet:function(d){
    		 			 return localFormatter(d.ischeck)}
    		 	 },
			     {field : 'checker',align : 'center',title : '审核人'},
			     {title : '操作',toolbar : '#barDemo',align : 'center',width : 180} 
			     ] 
			 ],
			 page: {
					layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'],
					groups: 5,
					limit: 10,
					limits: [10, 20, 30, 40, 50],
					theme: '#1E9FFF',						
			 },
		});
		
		//table监听工具条
		table.on('tool(notice)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
		  var data = obj.data; //获得当前行数据
		  var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
		  var tr = obj.tr; //获得当前行 tr 的DOM对象
		 
		  if(layEvent === 'delete'){ //删除
		    layer.confirm('真的删除行么', function(index){
		      obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
		      layer.close(index);
		      //向服务端发送删除指令
		      	$.post("../../oilmana/deletenoil",{oilingid:obj.data.oilingid},function(flag){
		      		//alert(flag.code)
	    			if(flag.code == 0){
	    				layer.msg("刪除成功",{icon:6}); //表格刷新
				        table.reload('oil'); //重载表格	
	    			}else{
	    				layer.msg("刪除失敗",{icon:5});
	    			}
		    	});
		    });
		  } else if(layEvent === 'edit'){ //审核
		  		if(obj.data.ischeck == 2){
		  			layer.msg("当前数据已审核",{icon:6});
		  			return;
		  		}else if(obj.data.ischeck == 3){
		  			layer.msg("当前数据已经拒审",{icon:6});
		  			return;
		  		}
			   layer.confirm('确定审核?', function(index){
			      layer.close(index);
			      //向服务端发送删除指令
			      	$.post("../../oilmana/checkoil",{oilingid:obj.data.oilingid},function(flag){
			      		//alert(flag.code)
		    			if(flag.code == 0){
		    				layer.msg("审核成功",{icon:6}); //表格刷新
					        table.reload('oil'); //重载表格	
		    			}else{
		    				layer.msg("审核失敗",{icon:5});
		    			}
			    	});
			    });
		  }else if(layEvent === 'uncheck'){ //拒绝审核
		  		if(obj.data.ischeck == 2){
		  			layer.msg("当前数据已审核",{icon:6});
		  			return;
		  		}
		  		if(obj.data.ischeck == 3){
		  			layer.msg("当前数据已拒审",{icon:6});
		  			return;
		  		}
			   layer.confirm('确定拒审?', function(index){
			      layer.close(index);
			      //向服务端发送删除指令
			      	$.post("../../oilmana/uncheckoil",{oilingid:obj.data.oilingid},function(flag){
			      		
		    			if(flag.code == 0){
		    				layer.msg("拒审成功",{icon:6}); //表格刷新
					        table.reload('oil'); //重载表格	
		    			}else{
		    				layer.msg("拒审失敗",{icon:5});
		    			}
			    	});
			    });
		  }
	  });
});
	
	</script>
</body>
</html>